package com.jk.lesson3;

import com.jk.lesson2.Apple;

import java.util.Arrays;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Created by Auser on 2016/11/8.
 */
public class ComparatorTest {
    public static void main(String...args){
        List<String> str = Arrays.asList("a", "b", "c", "A", "B", "C");
//        str.sort((o1, o2) -> o1.compareToIgnoreCase(o2));
        str.sort(String::compareToIgnoreCase);
        System.out.println(str.toString());

        List<Integer> in = Arrays.asList(8,1,2,3,4,5);
        in.sort(Integer::compareTo);
        System.out.println(in.toString());

        Function<String, Integer> stringToInteger = s -> Integer.parseInt(s);
        int a = stringToInteger.apply("123");
        Function<String, Integer> stringToInteger2 = Integer::parseInt;
        int b = stringToInteger2.apply("456");

        BiPredicate<List<String>, String> contains = (strings, s) -> strings.contains(s);
        contains = List::contains;
        boolean b1 = contains.test(str, "c");
        boolean b2 = contains.test(str, "E");
        System.out.println(b1);
        System.out.println(b2);

        Supplier<Apple> c1 = Apple::new;
        Apple a1 = c1.get();
        a1.setColor("red");
        Apple a2 = c1.get();
        a2.setColor("green");

        System.out.println(a1.toString());
        System.out.println(a2.toString());

        BiFunction<String, Integer, Apple> c2 = Apple::new;
        Apple a3 = c2.apply("red", 120);
        System.out.println(a3.toString());

    }}
